package com.star.carservice.client.activity;

import com.star.carservice.R;
import com.star.carservice.client.activity.base.BaseActivity;
import com.star.carservice.client.fragment.RegisterStep1Fragment;
import com.star.carservice.client.fragment.SelectCarBrandFragment;
import com.star.carserviceapi.domain.CarFeatureInfo;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class SelectCarActivity extends BaseActivity {

	public final static String KEY_CAR = "KEY_CAR";

	public static void pop(Context context) {
		Intent intent = new Intent(context, SelectCarActivity.class);
		context.startActivity(intent);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_placeholder);

		if (savedInstanceState == null) {
			getSupportFragmentManager()
					.beginTransaction()
					.replace(R.id.view_placeholder,
							new SelectCarBrandFragment()).commit();
		}
	}

	public void onSelectCar(CarFeatureInfo carFeatureInfo) {
		Intent intent = new Intent();

		Bundle extras = new Bundle();

		extras.putSerializable(KEY_CAR, carFeatureInfo);

		intent.putExtras(extras);

		setResult(RESULT_OK, intent);
		finish();
	}

}
